import {createStore} from 'vuex'

const store = createStore({
    state() {
        return {
            keepAliveList: [],
            viewLoading: false
        }
    },
    getters: {
        getViewLoading: (state) => {
            return state.viewLoading
        }
    },
    mutations: {
        PUSH_KEEPALIVE: (state, payload) => {
            if (state.keepAliveList.indexOf(payload) === -1) {
                state.keepAliveList.push(payload)
            }
        },
        CHANGE_LOADING: (state, payload) => {
            state.viewLoading = payload
        }
    },
    actions:{
        changeLoading({commit}, payload) {
            commit('CHANGE_LOADING',payload)
        },
    }
})

export default store
